package client;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.List;

import common.IAuctionServer;
import common.Item;

public class TestClient {

	public static void main(String args[]) {
		
		while (true) {
		
			try {
				Registry registry = LocateRegistry.getRegistry(10778);
				
				IAuctionServer server = (IAuctionServer) registry.lookup("Server");
				
				BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
			    String itemName = bufferedReader.readLine();
			    String auctionTime = bufferedReader.readLine();
				
				server.placeItemForBid("Bartek", itemName, "Item1 description", 0.9, Integer.parseInt(auctionTime));
				List<Item> itemy = server.getItems();
				for (Item item : itemy)
					System.out.println(item.getName()+"\n");
			
			} 
			catch (RemoteException e) {
				System.out.println(e);
			}
			catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
}
